package com.ykt.model;

import com.jfinal.plugin.activerecord.Page;

import java.util.List;
import java.util.Map;

/**
 * 订单项
 * @author wing
 * @version 1.0.0
 */
public class OrderItem extends BaseModel<OrderItem> {
	private static final long serialVersionUID = 1L;

    public static final String order_id = "order_id";
    public static final String goods_id = "goods_id";
    public static final String goods_no = "goods_no";
    public static final String goods_name = "goods_name";
    public static final String goods_price = "goods_price";
    public static final String goods_count = "goods_count";
    public static final String goods_unit = "goods_unit";
    public static final String goods_amount = "goods_amount";
    public static final String goods_pcs = "goods_pcs";

    public static final OrderItem dao = new OrderItem();


	@Override
    public Page<OrderItem> pageFindModel(int pageNumber, int rows, Map<String, String> paramMap) {
        String select = "SELECT i.* ";
        String sqlExceptSelect = " FROM order_item i ";
        paramMap.put("EQ_i.order_id", paramMap.get("o.id"));
        return this.pageFindModel(select, sqlExceptSelect, pageNumber, rows, paramMap);
    }
    
    /**
     * 根据 order id 查询订单中所含商品信息
     * @param orderId 订单编号
     * @return 订单项概要信息
     */
    public List<OrderItem> findByOrderId(int orderId){
        String sql = "SELECT * FROM order_item WHERE order_id=? ";

        return this.find(sql, orderId);
    }
}
